package com.usian.controller;

import com.usian.pojo.Stock;
import com.usian.service.StockServcice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/stock")
public class StockController {

    @Autowired
    private StockServcice stockServcice;

    /**
     * 扣减库存
     *
     * @param stock
     * @return
     */
    @PostMapping("/DeductionStock")
    public String DeductionStock(@RequestBody Stock stock){
        stockServcice.DeductionStock(stock);
        return "succ";
    }

    /**
     * 根据skuId查询商品库存对象
     *
     * @param skuId
     * @return
     */
    @GetMapping("/findBySkuId")
    public Stock findBySkuId(@RequestParam Integer skuId){
        return stockServcice.findBySkuId(skuId);
    }
}
